#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main()
{
    int year = 0;
    int month = 0;
    int day = 0;
    int d = 0;
    int ar1[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
    int ar2[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };

    scanf("%d %d %d", &year, &month, &day);
    if (year % 100 != 0)
    {
        if (year % 4 == 0)
        {
            for (int i = 0; i < month - 1; ++i)
            {
                d = d + ar2[i];
            }
        }
        else
        {
            for (int i = 0; i < month - 1; ++i)
            {
                d = d + ar1[i];
            }
        }
    }
    else
    {
        if (year % 400 == 0)
        {
            for (int i = 0; i < month - 1; ++i)
            {
                d = d + ar2[i];
            }
        }
        else
        {
            for (int i = 0; i < month - 1; ++i)
            {
                d = d + ar1[i];
            }
        }
    }
    d = d + day;
    printf("%d", d);
    return 0;
}